package com.libinshen.wxpay.common.util.common;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/***
 * 微信第三方配置，这个方法可以被优化掉
 */
@Component
public class PropertiesUtils implements InitializingBean {

    /*下面三个是阿里云短信服务需要的参数*/
    @Value("${aliyun.sms.regionId}")
    private String regionId;

    @Value("${aliyun.sms.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.sms.accessKeySecret}")
    private String secret;

    /*下面两个是微信登录需要配置参数*/
    @Value("${wx.open.app_id}")
    private String appId;

    @Value("${wx.open.app_secret}")
    private String appSecret;

    /*下面四个是阿里云 OSS 服务需要的配置*/
    @Value("${oss.accessKeyId}")
    private String ossAccessId;

    @Value("${oss.accessKeySecret}")
    private String accessKeySecret;

    @Value("${oss.bucketName}")
    private String bucketName;

    @Value("${oss.endpoint}")
    private String endpoint;

    /*阿里云短信*/
    public static String REGIONID;
    public static String ACCESSKEYID;
    public static String SECRET;

    /*阿里云Oss文件存储服务需要的参数*/
    public static String OSS_ACCESS_KEY_ID;
    public static String OSS_ACCESS_SECRET;
    public static String OSS_ENDPOINT;
    public static String OSS_BUCKETNAME;

    /*微信登录*/
    public static String WX_OPEN_APP_ID;
    public static String WX_OPEN_APP_SECRET;

    @Override
    public void afterPropertiesSet() {
        /*阿里云短信*/
        REGIONID = regionId;
        ACCESSKEYID = accessKeyId;
        SECRET = secret;

        /*阿里云Oss文件存储服务需要的参数*/
        OSS_ACCESS_KEY_ID = ossAccessId;
        OSS_ACCESS_SECRET = accessKeySecret;
        OSS_ENDPOINT = endpoint;
        OSS_BUCKETNAME = bucketName;

        /*微信登录*/
        WX_OPEN_APP_ID = appId;
        WX_OPEN_APP_SECRET = appSecret;
    }
}
